package ua.kharkov.khpi.tarasenko.bach.analysis.prefixspan;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Node {
	private Item item;
	private Node parent;
	private Map<String, Node> children;
	private int support;

	public Node() {
		setChildren(new HashMap<String, Node>());
	}

	public Node(Node old) {
		this.item = old.item;
		this.parent = old.parent;
		this.support = old.support;
		this.setChildren(new HashMap<String, Node>(old.getChildren()));
	}

	public Item getItem() {
		return item;
	}

	public String getItemS() {
		return item.getItem();
	}

	public void setItem(Item item) {
		this.item = item;
	}

	public int getSupport() {
		return item.getSupport();
	}

	public void setSupport(int support) {
		item.setSupport(support);
		this.support = support;
	}

	public Node getParent() {
		return parent;
	}

	public void setParent(Node parent) {
		this.parent = parent;
	}

	public void addChildNode(Node child) {
		getChildren().put(child.getItem().getItem(), child);
	}

	public List<Node> getChildrenNodes() {
		List<Node> values = new ArrayList<Node>();
		for (Node node : getChildren().values()) {
			values.add(node);
		}
		return values;
	}

	public Node getChildNode(String item) {
		Node child = getChildren().get(item);
		return child;
	}

	public boolean hasChildren() {
		return (getChildren().size() > 0);
	}

	public Map<String, Node> getChildren() {
		return children;
	}

	public void setChildren(Map<String, Node> children) {
		this.children = children;
	}

}
